<template>
  <div class="login-btn">
    <CommonButton @click="Login()" :title="'登录'" />
  </div>
</template>

<script>
import CommonButton from './CommonButton.vue'

import { UseLoginStore } from '../../stores/request'
import { bus } from '../../utils/utils'
export default {
  name: 'LoginButton',
  components: {
    CommonButton
  },
  setup() {
    const LoginStore = UseLoginStore()
    function Login() {
      LoginStore.Login((status) => {
        if (status === 204) {
          bus.emit('errStyle', 'admin')
        } else {
          bus.emit('errStyle', 'password')
        }
      })
    }

    return {
      LoginStore,
      Login
    }
  }
}
</script>

<style lang="scss" scoped>
.login-btn {
  background-color: $primary;
}
</style>
